// pages/VolumeData/VolumeData.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        volumeData: "",
        volume_data_id: "",
        station_layout: {//站姿
            normal: "普通",
            raised_chest: "挺胸",
            humpbacked: "驼背",
            coax_back: "哄背"
        },
        shoulder: {//肩宽
            normal: "普通",
            xiaoping_shoulder: "小平肩",
            daping_shoulder: "大平肩",
            small_shoulder: "小溜肩",
            big_shoulder: "大溜肩"
        },
        abdomen: {//腹部
            flat_belly: "平腹",
            micro_abdominal: "微腹",
            upper_abdomen: "大腹"
        },
        body_shape: {//体型
            normal: "一般",
            thin: "纤细",
            rich: "富贵",
            little_fat: "微胖",
            strong: "强壮"
        },
        loading_show:true
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        this.init();
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    init: function () {
        var that = this;
        wx.getStorage({
            key: 'memberInfo',
            success: function (res) {
                var data = res.data;
                var member_id = data.id;
                that.member_details(member_id);
            }
        })
    },
    member_details: function (member_id) {
        var that = this;
        var params = {};
        params['id'] = member_id;
        wx.request({
            url: app.config() + "member/memberDetail",
            data: params,
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
                var data = res.data.data;
                var len=data.length;
                if(len){
                    for (var i = 0; i < data.length; i++) {
                        var create_time = data[i].create_time;
                        data[i].create_time = app.to_time(create_time);
                        data[i].selected = false;
                    }
                }else{
                    that.setData({
                        loading_show:false
                    })
                }
                
                that.setData({
                    volumeData: data
                })
            }
        })
    },
    viewDetails: function (e) {
        var that = this;
        var volumeData = that.data.volumeData;
        var id = e.currentTarget.dataset.id;
        var index = e.currentTarget.dataset.index;
        volumeData[index]['selected'] = !volumeData[index]['selected'];
        that.setData({
            volume_data_id: id,
            volumeData: volumeData
        })
    }
})